package com.hxht.cmp.controller;

import com.google.gson.JsonArray;
import com.hxht.cmp.common.enums.ResultCode;
import com.hxht.cmp.common.result.ResultResponse;
import com.hxht.cmp.service.DeviceService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/device")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    /**
     * 获取庭审主机状态
     *
     * @param courtUid
     * @return
     */
    @RequestMapping("/getDevStatus")
    @ResponseBody
    public ResultResponse getDevStatus(String courtUid) {
        if (StringUtils.isBlank(courtUid)) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        JsonArray jsonArray = deviceService.getDevStatus(courtUid);
        return ObjectUtils.isEmpty(jsonArray) ? ResultResponse.failed() : ResultResponse.success(jsonArray);
    }
}
